<%@ page import="com.vo.Classes" %>
<%@ page import="com.factory.DAOFactory" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加学生信息</title>
    <!-- 引入 Bootstrap CSS -->
    <link href="vendor/bootstrap-5.3.0/css/bootstrap.min.css" rel="stylesheet">
    <style>
        :root {
            --primary-color: #005eb6;
            --secondary-color-1: #117e42;
            --secondary-color-2: #ffd700;
            --neutral-dark: #2e2e2e;
            --neutral-light: #ffffff;
            --neutral-gray-dark: #c4c4c4;
            --neutral-gray-light: #e2e2e2;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: var(--neutral-light);
            color: var(--neutral-dark);
        }

        .header {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color-1));
            color: white;
            padding: 1rem 0;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .form-container {
            max-width: 600px;
            margin: 2rem auto;
            padding: 2rem;
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
        }

        .form-title {
            text-align: center;
            margin-bottom: 2rem;
            color: var(--primary-color);
        }

        .form-group {
            margin-bottom: 1.5rem;
        }

        .form-control {
            border-radius: 5px;
            padding: 0.8rem;
            border: 1px solid var(--neutral-gray-light);
        }

        .form-control:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 0.2rem rgba(0, 94, 182, 0.25);
        }

        .radio-group {
            display: flex;
            gap: 1rem;
        }

        .radio-btn {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        select.form-select {
            border-radius: 5px;
            padding: 0.8rem;
            border: 1px solid var(--neutral-gray-light);
        }

        .btn-submit {
            background-color: var(--primary-color);
            color: white;
            border: none;
            padding: 0.8rem 1.5rem;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .btn-submit:hover {
            background-color: #004a8c;
        }

        .btn-return {
            background-color: var(--neutral-gray-dark);
            color: white;
            border: none;
            padding: 0.8rem 1.5rem;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-left: 1rem;
        }

        .btn-return:hover {
            background-color: #888888;
        }

        .form-label {
            display: block;
            margin-bottom: 0.5rem;
            font-weight: 600;
        }
    </style>
</head>
<body>
<!-- 页面标题 -->
<header class="header text-center">
    <h1>学生信息管理系统</h1>
</header>

<!-- 表单容器 -->
<div class="form-container">
    <h2 class="form-title">添加学生信息</h2>
    <form action="insertStudentsAction.jsp" method="post">
        <div class="form-group">
            <label class="form-label">学号：</label>
            <input type="text" class="form-control" name="studentId" required>
        </div>
        <div class="form-group">
            <label class="form-label">姓名：</label>
            <input type="text" class="form-control" name="studentName" required>
        </div>
        <div class="form-group">
            <label class="form-label">密码：</label>
            <input type="password" class="form-control" name="studentPwd" required>
        </div>
        <div class="form-group">
            <label class="form-label">性别：</label>
            <div class="radio-group">
                <div class="radio-btn">
                    <input type="radio" name="gender" value="男" checked>
                    <label>男</label>
                </div>
                <div class="radio-btn">
                    <input type="radio" name="gender" value="女">
                    <label>女</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="form-label">班级：</label>
            <select class="form-select" name="classId" required>
                <option value="" selected disabled>请选择班级</option>
                <%
                    List<Classes> allClasses = null;
                    try {
                        allClasses = DAOFactory.getClassesDAOInstance().findAllClasses();
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                    if (allClasses != null && !allClasses.isEmpty()) {
                        for (Classes classes : allClasses) {
                %>
                <option value="<%= classes.getClassId() %>"><%= classes.getClassName() %></option>
                <%
                        }
                    }
                %>
            </select>
        </div>
        <div class="text-center">
            <button type="submit" class="btn-submit">提交</button>
            <button type="button" class="btn-return" onclick="window.location.href='showStudents.jsp'">返回</button>
        </div>
    </form>
</div>

<!-- 引入 Bootstrap JS 和依赖的 Popper.js -->
<script src="vendor/bootstrap-5.3.0/js/bootstrap.bundle.min.js"></script>
</body>
</html>